import http from '@/utils/http'

const BASE_URL = '/card/company'

export interface CompanyResp {
  id: string
  name: string
  longitude: string
  latitude: string
  address: string
  description: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface CompanyDetailResp {
  id: string
  name: string
  longitude: string
  latitude: string
  address: string
  description: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface CompanyQuery {
  description?: string,
  sort: Array<string>
}
export interface CompanyPageQuery extends CompanyQuery, PageQuery { }

/** @desc 查询公司列表 */
export function listCompany(query?: CompanyPageQuery) {
  return http.get<PageRes<CompanyResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询公司详情 */
export function getCompany(id: string) {
  return http.get<CompanyDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增公司 */
export function addCompany(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改公司 */
export function updateCompany(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除公司 */
export function deleteCompany(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出公司 */
export function exportCompany(query: CompanyQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
